package com.twu.biblioteca;

import java.util.LinkedList;
import java.util.List;

public class Moviestore {

    private static final Moviestore instance = new Moviestore();

    private final List<Movie> available;
    private final List<Movie> rent;

    private Moviestore () {
        this.available = new LinkedList<Movie>();
        this.rent = new LinkedList<Movie>();

        this.available.add(new Movie("Super Movie", "1951", "James John", "4"));
        this.available.add(new Movie("Ching Chang", "1932", "Xia Ling", "10"));
        this.available.add(new Movie("Spiderwoman", "2010", "Franz Schwarz", "unrated"));
    }

    public static Moviestore getInstance() {
        return instance;
    }

    public List<Movie> getAvailableMovies() {
        List<Movie> tmp = new LinkedList<Movie>();
        tmp.addAll(this.available);
        return tmp;
    }

    public boolean checkoutMovie(Movie movie) {
        if (available.contains(movie)) {
            available.remove(movie);
            rent.add(movie);
            return true;
        }
        return false;
    }
}
